package studychinese.utils;

import java.util.List;

/**
 * Created by lenovo on 2017/5/25.
 */

public class ListToStringUtil {
    public static  String listToString(List<String> list, String separator) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < list.size(); i++) {
            sb.append(list.get(i)).append(separator);
        }
        String substring="";
        if(sb.toString().length()>0){
            substring = sb.toString().substring(0, sb.toString().length() - 1);
        }else {
             substring = sb.toString().substring(0, 0);
        }

        return substring;
    }
    public static  String listToString1(List<Integer> list, String separator) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < list.size(); i++) {
            sb.append(list.get(i)).append(separator);
        }
        String substring="";
        if(sb.toString().length()>0){
            substring = sb.toString().substring(0, sb.toString().length() - 1);
        }else {
             substring = sb.toString().substring(0, 0);
        }

        return substring;
    }


    public static  List<String> stringTolist(String str) {
        String[] arrayStr =new String[]{};

        arrayStr = str.split(",");
        List list = java.util.Arrays.asList(arrayStr);
        return list;
    }



}
